using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

namespace ProductExpirationAssistant
{
    [RequireComponent(typeof(Toggle))]
    public class ToggleData : MonoBehaviour
    {
        public FunctionType type;
        public bool isOn => m_Toggle.isOn;
        public UnityEvent<ToggleData> onStateChanged = new UnityEvent<ToggleData>();

        private Toggle m_Toggle;

        private void Awake()
        {
            m_Toggle = GetComponent<Toggle>();

            m_Toggle.onValueChanged.AddListener((bool b) => { onStateChanged.Invoke(this); });
        }
    }
}